package timmytest;
import java.util.*;
import search.*;
/**
 * 
 * 
 * @Thomas Kingston
 * 
 */
//made by Rudi Lutz
public class Test   
{
    CityMap map;
    
    //made by Rudi Lutz
    public Test()
    {
        map = makeMap();
    }
    
    //made by Rudi Lutz
    private CityMap makeMap()
    {
        CityMap map = new CityMap();
        City london = new City("London");
        City brighton = new City("Brighton");
        City hove = new City("Hove");
        City worthing = new City("Worthing");
        City birmingham = new City("Birmingham");
        Road m1 = new Road(london,birmingham, 150);
        Road a23 = new Road(london, brighton, 55);
        Road a27 = new Road(brighton,hove,6);
        Road another = new Road(hove, worthing, 15);
        Road yetAnother = new Road(worthing,london,60);
        map.addEdge(another);
        map.addEdge(yetAnother);
        map.addEdge(a23);
        map.addEdge(a27);
        map.addEdge(m1);
        return map; 
    }
    // orginally made by Rudi Lutz, edited by Thomas Kingston
    public void findRoute(String start, String end)
    {
    	TravellingSalesmanStateSpace ts = new TravellingSalesmanStateSpace();
    	TourFinder t = new TourFinder(map, start, end);
    	SearchNode<TourState> node = ts.accept(t);
    	printRoute(node);
    }
    //made by Rudi Lutz
    public void printRoute(SearchNode<TourState> x)
    {
        if (x == null) {
            return;
        }
        else {
            printRoute(x.getParent());
            System.out.println(x.getState().getData()); 
        }
    }
    public static void main(String[] args) {
		new Test().findRoute("Worthing", "Birmingham");
	}
}
